package sys.message;

import org.json.*;

public class JSONMessage extends UniMessage
{
    public JSONMessage(String from, String to, String subj, String body) throws JSONException
    {
        this.to = to;
        this.from = from;
        this.subj = subj;
        this.body = body;
        jo = new JSONObject(this.body);
    }

    public JSONMessage(String from, String to, String subj)
    {
        this.to = to;
        this.from = from;
        this.subj = subj;
        jo = new JSONObject(); 
    }

    public String getBody()
    { 
        return jo.toString(); 
    }


    public Object get(String key) throws JSONException
    {
        return jo.get(key);
    }

    public String getString(String key) throws JSONException
    {
        return jo.getString(key);
    }

    public int getInt(String key) throws JSONException
    {
        return jo.getInt(key);
    }

    public double getDouble(String key) throws JSONException
    {
        return jo.getDouble(key);
    }

    public void put(String key, Object value) throws JSONException
    {
        jo.put(key, value);
    }

    public void put(String key, String value) throws JSONException
    {
        jo.put(key, value);
    }

    public void put(String key, int value) throws JSONException
    {
        jo.put(key, value);
    }

    public void put(String key, double value) throws JSONException
    {
        jo.put(key, value);
    }

    JSONObject jo;
}
